<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import=" vn.edu.ptithcm.helper.CKEditorConfigHelper" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
  <spring:message  code="pim"/> - <spring:message  code="homepage.project"/>&nbsp;
  <c:out value="${bean.project.name}"></c:out> - <spring:message  code="project.add.task" />
</title>
<link href="<%= request.getContextPath() %>/css/custom.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/v.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/jquery.ui.all.css" rel="stylesheet" />
<link href="<%= request.getContextPath() %>/css/uploadify.css" rel="stylesheet" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.14.custom.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.uploadify.v2.1.4.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/swfobject.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/AC_OETags.js"></script>
<%@include file="script/pim-util.jsp" %>
<%@include file="script/task-script.jsp" %>
</head>
<body>
<c:if test="${bean.isSigned == true}">
<div id="all">
<div id="wrapper">
<div id="mainheader">
	<jsp:include page="include/common/headerSignedIn.jsp" />
</div> 
<div id="content-wrapper">
<div id="top-menu">
    <jsp:include page="include/common/topMenuHome.jsp" /> 
</div>
<div class="workspace-menu-top">
    <c:choose>
    <c:when test="${bean.isAdmin == true}">
      <jsp:include page="include/common/admin-menu.jsp" />
    </c:when>
    <c:otherwise>
      <jsp:include page="include/common/user-menu.jsp" />
    </c:otherwise>
   </c:choose> 
</div>

<div class="main-content">
<form:form action="" method="post" commandName="task" name="addTasks" acceptCharset="UTF-8" enctype="multipart/form-data">	   		  
<div>	
	<div class="v-row v-border-bottom" style="padding-top: 10px;">
		<div class="v-row-left" style="margin-left: 10px;">
			<span class="v-title">
				<spring:message  code="project.add.task" />
			</span>
		</div>	
	</div>	
	<div class="v-body">
	<div class="v-row" id="v-global-message">
	   <c:if test="${addOK == true }">
	      	<span class="v-global-success-message v-row">
	      	    <span><spring:message  code="handle.add.task.success" /></span>
	      	</span>
	   </c:if>
	   <c:if test="${addOK == false }">
	      	<span class="v-global-error-message v-row">
	      	    <span><spring:message  code="handle.add.task.error" /></span>
	      	</span>
	    </c:if>
	</div>	
	<div style="margin-left: 40px;">
		<div class="v-row">
			<div class="v-row-left">
				<span class="v-required-title">
				    <spring:message code="title.required.field" />
				</span>
			</div>
		</div>
		<c:if test="${bean.isChildTask == true }">
		<div class="v-row">
			<div class="v-row-left">
				<span>
			     	<spring:message code="title.required.task.parent" />
				</span>
			</div>			
			<div class="v-row-right eighty">
			     <div>
					 <span>
					    <input class="v-input-small" name="parent_tcode" disabled="disabled"  value="${bean.parent_tcode}"/>		
					 </span>			
				 </div>
			</div>
		</div>			
		</c:if>
		<div class="v-row">
			<div class="v-row-left">
				<span>
				    <spring:message code="title.required.task.category" />
				</span>
			</div>			
			<div class="v-row-right eighty">			    
				  <span>
                     <form:select path="taskCategory.categoryid" cssClass="v-select-small">
                        <option value="0"><spring:message code="please.choice" /></option>
                        <c:forEach var="category" items="${bean.categories}">
                         <option value="${category.categoryid}"
                               <c:if test="${task.taskCategory.categoryid == category.categoryid}">
                                     selected="selected"</c:if>>
                               <c:out value="${category.name}" />
                         </option>
                        </c:forEach>
                     </form:select>				    
				 </span>				 
				<form:errors path="taskCategory" cssClass="v-error-message" />				
			</div>
		</div>		
		<div class="v-row">
			<div class="v-row-left">
				<span>
				    <spring:message code="title.required.task.severity" />
				</span>
			</div>			
			<div class="v-row-right eighty">			   
				<span>
				    <span>
                     <form:select path="taskSeverity.severityid" cssClass="v-select-small">
                        <option value="0"><spring:message code="please.choice" /></option>
                        <c:forEach var="severity" items="${bean.severities}">
                         <option value="${severity.severityid}"
                               <c:if test="${task.taskSeverity.severityid == severity.severityid}">
                                     selected="selected"</c:if>>
                               <c:out value="${severity.name}" />
                         </option>
                        </c:forEach>
                     </form:select>				    
				   </span>
				</span>				
				<form:errors path="taskSeverity" cssClass="v-error-message" />				
			</div>
		</div>		
		<div class="v-row">
			<div class="v-row-left">
				<span>
				       <spring:message code="title.required.task.priority" />
				</span>
			</div>			
			<div class="v-row-right eighty">
				<span>
                     <form:select path="taskPriority.priorityid" cssClass="v-select-small">
                        <option value="0"><spring:message code="please.choice" /></option>
                        <c:forEach var="priority" items="${bean.priorities}">
                         <option value="${priority.priorityid}"
                               <c:if test="${task.taskPriority.priorityid == priority.priorityid}">selected="selected"</c:if>>
                               <c:out value="${priority.name}" />
                         </option>
                        </c:forEach>
                     </form:select>				    
				 </span>
				 <form:errors path="taskPriority" cssClass="v-error-message" />				
			</div>
		</div>		
		<div class="v-row">
			<div class="v-row-left">
				<span>
				       <spring:message code="task.monitoredby" />
				</span>
			</div>
			<div class="v-row-right eighty">
				<span>
                    <form:select path="monitoredby" cssClass="v-select-small">
                        <option value=""><spring:message  code="please.choice" /></option>
                         <c:forEach var="efip" items="${bean.efips}">
                         <option value="${efip.employee.visa}"
                         <c:if test="${task.monitoredby == efip.employee.visa}">
                                     selected="selected"
                               </c:if> >
                               <c:out value="${efip.employee.visa}" />
                         </option>
                        </c:forEach>
                   </form:select>			    
				 </span>			
			</div>
		</div>			
		<div class="v-row">
			<div class="v-row-left">
				<span>
				       <spring:message code="task.assignedto" />
				</span>
			</div>
			<div class="v-row-right eighty">
				<span>
                    <form:select path="assignedto" cssClass="v-select-small">
                        <option value=""><spring:message  code="please.choice" /></option>
                         <c:forEach var="efip" items="${bean.efips}">
                         <option value="${efip.employee.visa}"                            
                               <c:if test="${task.assignedto == efip.employee.visa}">
                                     selected="selected"
                               </c:if>>
                               <c:out value="${efip.employee.visa}" />
                         </option>
                        </c:forEach>
                   </form:select>			    
				 </span>			
			</div>
		</div>	                 	    
	    <div class="v-row">
			<div class="v-row-left">
				<span>
				     <spring:message code="title.required.task.status" />
				</span>
			</div>
			<div class="v-row-right eighty">
				<span>
                    <form:select path="taskStatus.statusid" cssClass="v-select-small">
                        <c:forEach var="status" items="${bean.statuses}">
                         <option value="${status.statusid}"
                               <c:if test="${task.taskStatus.statusid == status.statusid}">selected="selected"</c:if>>
                               <c:out value="${status.name}" />
                         </option>
                        </c:forEach>
                    </form:select>		    
				 </span>
				 <form:errors path="taskStatus" cssClass="v-error-message" />			
			</div>
		</div>	 		             
		<div class="v-row">
			<div class="v-row-left">
				<span>
			     	<spring:message code="title.required.task.summary" />
				</span>
			</div>			
			<div class="v-row-right eighty">
			    <div>
				<span>
				    <form:input path="summary" maxlength="200" cssStyle="width:725px;"/>		
				 </span>
				 <br/>
				<form:errors path="summary" cssClass="v-error-message" />
				 </div>
			</div>
		</div>		
		<div class="v-row">
			<div class="v-row-left">
				<span>
			     	<spring:message code="title.required.task.description" />
				</span>
			</div>			
			<div class="v-row-right eighty">			   
				<span>
				    <form:textarea cols="78" rows="8" path="description" cssClass="description"/>		
				 </span>
				 <br/>
				<form:errors path="description" cssClass="v-error-message" />				
			</div>
		</div>		
		<div class="v-row">
			<div class="v-row-left">
				<span>
			     	<spring:message code="task.additionalinformation" />
				</span>
			</div>			
			<div class="v-row-right eighty">			    
				<span>
					<form:textarea cols="78" rows="8" path="additionalinformation"  cssClass="additionalinformation"/>		
				 </span>
				 <br/>				
			</div>
		</div>			
		<div class="v-row">
		    <div class="v-row-left">
		         <span>
		           <spring:message code="title.required.task.starttime"/>
		         </span>
		    </div>		    
		    <div class="v-row-right eighty">		         
		         <span>
		              <form:input path="starttime" cssClass="v-input-small"/>
				 </span>
		         <br/>
		         <form:errors path="starttime" cssClass="v-error-message" />		        
		    </div>
		</div>		
		<div class="v-row">
		    <div class="v-row-left">
		         <span>
		           <spring:message code="title.task.endtime"/>
		         </span>
		    </div>		    
		    <div class="v-row-right eighty">		         
		         <span>
		              <form:input path="endtime" cssClass="v-input-small"/>
				 </span>
		         <br/>
		         <form:errors path="endtime" cssClass="v-error-message" />		        
		    </div>
		</div>		
		<div class="v-row">
			<div class="v-row-left">
				<span>
			     	<spring:message code="task.phase" />
				</span>
			</div>			
			<div class="v-row-right eighty">
			   <span>			    
				<form:select path="phase" cssClass="v-select-small">
		                <option value=""><spring:message  code="please.choice" /></option>
                        <c:forEach var="phase" items="${bean.phases}">
                         <option value="${phase.name}"
                               <c:if test="${task.phase == phase.name}">selected="selected"</c:if>>
                               <c:out value="${phase.name}" />
                         </option>
                        </c:forEach>
		        </form:select>	
		      </span>			
			</div>
		</div>		
		<div class="v-row">
			<div class="v-row-left">
				<span>
			     	<spring:message code="task.attachedfiles" />
				</span>
			</div>			
			<div class="v-row-right eighty">
			    <input name="fileUploads" id="fileUploads" type="file" size="50" />
			</div>				
		</div>		
		<div id="nosupportFlash" class="v-row" style="display: none;">
            <h4>Your browser don't support to the flash now! Please choose the other browser.</h4>
        </div>                    				
		<div class="v-row">
		    <br/>
			<div class="v-row-center">
				<span>
				<input type="button" onclick="startUpload('fileUploads');" class="bt-form" 
				       value="<spring:message code="button.save" />"/>
				</span>				
				<span>
				<input type="button" class="bt-form" value="<spring:message code="button.cancel"/>" 
						onclick="cancel('<c:out value='${bean.returnToFullPageURL }'/>')"/>
				</span>
			</div>
		</div>
	</div>
</div>
</div>
<input type="hidden" name="_attachedfiles"/>
<input type="hidden" name="cmd" value="addTasks"/>
<input type="hidden" name="returnToFullPageURL" value="${bean.returnToFullPageURL}"/>
<input type="hidden" name="pnum" value="${bean.project.number}"/>
</form:form>	 	
</div>	
</div>
</div>
<div class="footer">
	<jsp:include page="include/common/footer.jsp" />
</div>
</div>			   
<ckeditor:replace basePath="/ckeditor/" replace="description" config="<%= CKEditorConfigHelper.createConfig(725) %>"/>
<ckeditor:replace basePath="/ckeditor/" replace="additionalinformation" config="<%= CKEditorConfigHelper.createConfig(725) %>"/>
</c:if>
</body>
</html>	